#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :test.py
# @Time      :2024/3/12 
# @Author    :CL
# @email     :1037654919@qq.com
import time

from fanyi import fanyi
from utils import proxies, mongo_manager
hippopx_images = mongo_manager("hippopx_images", db="car_images")
sucai_title_code = mongo_manager("sucai_title_code", db='car_images')

if  __name__ == '__main__':
    print()
    seeds = sucai_title_code.findAll({'title_en':None})
    for seed in seeds:
        time.sleep(3)
        keyword = str(seed['title']).replace('图片', '').replace('其他', '')
        try:

            if keyword == '':
                trans = fanyi(seed['title'])
                seed['title_en'] = trans
                seed['hippopx'] = 'invalid'
            else:
                trans = fanyi(keyword)
                seed['title_en'] = trans
            sucai_title_code.updateOne({'_id': seed['_id']}, seed)
        except:
            continue

